home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 August / Macworld (1999-08).dmg / Updaters / DiskExpress 3.0.2 Update / DiskExpress® Pro AppleScripts / DiskExpress and AppleScript < prev    next >
Encoding:
Text File  |  1999-05-24  |  21.0 KB  |  253 lines  |  [ttro/ttxt]

  1. DiskExpress® Pro AppleScripts
  2. This document describes the AppleScripts that are included in the DiskExpress Pro package and provides some guidelines for writing your own AppleScripts for use with DiskExpress Pro.
  3.  
  4. Contents
  5.  
  6. AppleScripts included with DiskExpress Pro
  7.   - Archive Files
  8.   - Clear Selected Files
  9.   - Get Disk Info
  10.   - Get File Info
  11.   - List Files
  12.   - Optimize Disk
  13.   - Optimize Disk Files
  14.   - Optimize Selected Files
  15.   - Set File Priority
  16.   - Set Selected Files
  17.  
  18. Writing Your Own AppleScripts For DiskExpress Pro
  19.  
  20. Dictionary for the DiskExpress Extension Suite
  21.  
  22. List of Errors Returned by the DiskExpress Extension Suite
  23.  
  24.  
  25. AppleScripts included with DiskExpress Pro
  26.  
  27. Archive Files 
  28. The Archive Files AppleScript is designed to allow you to move or copy files based on two types of criteria. You may choose to archive files based on their priority or on the last date they were accessed. Archiving by priority allows you to archive all files with  the priority you specify. For example, you could choose to archive all dormant files on your disk. Archiving by last access date allows you to archive all files which were last accessed prior to a date that you specify. For example, you could choose to archive all files which have not been used in the last six months.
  29.  
  30. In addition to allowing you to select the archiving criteria, the script lets you choose whether or not to delete items from the source disk once they have been archived, and gives you the option of replacing files in the destination that have the same name as files being archived.
  31.  
  32. You may use this script by double-clicking it or by dragging source folders or disks to the script. Successful completion of the script is signaled by two system beeps.
  33.  
  34.  
  35. Clear Selected Files
  36. The Clear Selected Files AppleScript clears the list of files selected for optimization for the indicated disk. The list of files selected for optimization contains the names of the files that will be optimized during a Selected Files optimization. For more information on the Selected Files optimization method refer to the DiskExpress Pro manual.
  37.  
  38. You may use this script by double-clicking it or by dragging disk icons to the script. Successful completion of the script is signaled by two system beeps.
  39.  
  40.  
  41. Get Disk Info
  42. The Get Disk Info AppleScript displays a dialog containing DiskExpress Pro information about the selected disk. The information displayed includes: the disk name, its current optimization index, the capacity and free space available on the disk, the last date on which the disk’s free space was erased, the date and method used for the most recent file optimization, the last date on which the disk’s directory was verified, and the date of the most recent verification of the disk’s media.
  43.  
  44. You may use this script by double-clicking it or by dragging disk icons to the script.
  45.  
  46.  
  47. Get File Info
  48. The Get File Info AppleScript displays a dialog containing DiskExpress Pro information about the selected file. The information displayed includes: the file name, whether or not the file is fragmented or anchored, the file’s priority, and the last time the file was accessed.
  49.  
  50. You may use this script by double-clicking it or by dragging file icons to the script.
  51.  
  52.  
  53. List Files
  54. The List Files AppleScript creates a text document listing files based on three types of criteria. You may choose to list files based on their priority, based on the last date they were accessed, or based on being selected for selected files optimization. Listing files by priority allows you to create a list of all files with  the priority you specify. For example, you could choose to list all active files on your disk. Listing files by last access date allows you to create a list of all files which were last accessed prior to a date that you specify. For example, you could choose to list all files which have not been used in the last six months.
  55.  
  56. You may use this script by double-clicking it or by dragging source folders or disks to the script. Successful completion of the script is signaled by two system beeps.
  57.  
  58.  
  59. Optimize Disk
  60. The Optimize Disk AppleScript tells DiskExpress Pro to optimize one or more disks according to their current settings in the Disk Options tab of the DiskExpress Pro control panel. You will be asked whether or not DiskExpress Pro should ignore user activity and input/output activity during the optimization, and whether or not DiskExpress Pro should shut down your computer after it has finished optimizing.
  61.  
  62. You may use this script by double-clicking it or by dragging disk icons to the script. This script makes no changes to the current disk options as set in the DiskExpress Pro control panel.
  63.  
  64. Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds.  The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
  65.  
  66.  
  67. Optimize Disk Files
  68. The Optimize Disk Files AppleScript tells DiskExpress Pro to perform only the Optimize Files activity on one or more disks. The Verify Media, Verify Directory and Erase Free Space activities are not performed regardless of their current settings in the Disk Options tab of the DiskExpress Pro control panel. You will be asked to specify the optimization method to be used, the means by which DiskExpress Pro should notify you in case of an error, whether or not DiskExpress Pro should ignore user activity and input/output activity during the Optimize Files activity, and whether or not DiskExpress Pro should shut down your computer after it has finished optimizing the files.
  69.  
  70. You may use this script by double-clicking it or by dragging disk or file icons to the script. Dragging file icons to the script specifies those files as the files to be optimized for a Selected Files optimization and replaces the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel.
  71.  
  72. Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds.  The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
  73.  
  74.  
  75. Optimize Selected Files
  76. The Optimize Selected Files AppleScript tells DiskExpress Pro to perform the Optimize Files activity using the Selected Files method on the indicated disk or disks. The script tells DiskExpress Pro to ignore user activity and input/output activity during the Optimize Files activity and tells DiskExpress Pro not to shut down the computer afterwards. The script displays a message when the Optimize Files activity is completed. 
  77.  
  78. This script is used by dragging the selected files to the script. Running this script replaces the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel.
  79.  
  80. Due to the way compiled AppleScripts behave, executing this script will cause optimization to stop if the script is located on the same volume as the one being optimized. There are two work-arounds.  The first option is to execute this script once and then lock this script. The second option is to uncheck the “Do not wait for optimization to finish” option when prompted.
  81.  
  82.  
  83. Set File Priority
  84. The Set File Priority AppleScript allows you to set the priority of one or more files. Once you set a file’s priority, DiskExpress Pro leaves the file with the priority you select. If you no longer wish to force a file to have a specific priority, choose the “Let DiskExpress Pro assign the priority” option in the Set File Priority dialog.
  85.  
  86. You may use this script by double-clicking it to set the priority of a single file, or by dragging folder or disk icons to the script to set the priority of all files contained in those folders and disks. Successful completion of the script is signaled by two system beeps.
  87.  
  88.  
  89. Set Selected Files
  90. The Set Selected Files AppleScript allows you to designate which files will be optimized during a Selected Files optimization. You will be asked whether the indicated files should be added to the list of files selected for optimization or if the files should replace the current list of files selected for optimization.
  91.  
  92. To use this script, drag the selected files to the script. Running this script changes the current list of files selected for selected files optimization as set in the DiskExpress Pro control panel. Successful completion of the script is signaled by two system beeps.
  93.  
  94.  
  95. Writing Your Own AppleScripts For DiskExpress Pro
  96.  
  97. The best way to learn about writing your own AppleScripts for DiskExpress Pro is to modify one of the scripts that comes with the product. For example, you might want to modify the Optimize Disk script so that it always optimizes without sensitivity and without waiting instead of asking you about optimization options.
  98.  
  99. In addition to examining the included AppleScripts, you should review the AppleScript dictionary for the DiskExpress® Pro Extension. You can view the dictionary by opening the Script Editor application, choosing Open Dictionary from the File menu, then selecting the DiskExpress® Pro Extension within the Extensions folder.
  100.  
  101. When writing your own AppleScripts for DiskExpress Pro, remember that all commands sent to DiskExpress and all information you wish to get from DiskExpress must be inside a tell application block. For example:
  102.  
  103. tell application "DiskExpress® Pro Extension"
  104.      optimize startup disk
  105. end tell
  106.  
  107. Notice that the application being sent the commands is the DiskExpress® Pro Extension.
  108.  
  109. As a final suggestion, AppleScript limitations make it inadvisable to issue AppleScript commands that will return a very large number of items. For example, avoid asking for every file of the entire contents of a disk that holds tens of thousands of files. At best the request will take a very long time to process. At worst the request will never be successfully completed at all due to the AppleScript limitations. When specifying the entire contents of a disk, use a test that will return a reasonable number of items. For example, returning every fragmented file of the entire contents of a disk.
  110.  
  111. An expanded listing of the DiskExpress® Pro Extension AppleScript dictionary is shown below for your reference.
  112.  
  113.  
  114. Dictionary for the DiskExpress Extension Suite
  115.  
  116. optimize: Optimize the specified disk(s)
  117.     optimize reference -- the disks to optimize  (a single disk or a list of disks)
  118.         [sensitivity  boolean] -- Should DiskExpress ignore user and i/o activity during optimization?  Default is true.
  119.         [shut down  boolean] -- Should DiskExpress shut down the computer after optimizing?  Default is false.
  120.         [waiting  boolean] -- Wait until optimization is completed before executing the rest of the script?  Default is  true.
  121.  
  122. optimize files: Perform the "Optimize Files" activity on the specified disk(s)
  123.     optimize files reference -- the disks to optimize  (a single disk or a list of disks) 
  124.         [method  split method/packed method/quick method/selected files method/free space method/unknown method] -- specifies the file optimization method to use.  Default is split method.
  125.         [files reference] -- specifies a list of files to optimize when using the selected files method of optimization. If the files parameter is not passed and the selected files optimization method is used, DiskExpress optimizes the files currently selected for optimization on the disk.  Default is an empty  list.
  126.         [reporting no reporting / flash menu icon / open control panel] -- specifies the manner in which DiskExpress should report errors which occur during the optimization.  Default is no reporting.
  127.         [sensitivity  boolean] -- Should DiskExpress ignore user and i/o activity during optimization?  Default is true.
  128.         [shut down  boolean] -- Should DiskExpress shut down the computer after optimizing?  Default is false.
  129.         [waiting  boolean] -- Wait until optimization is completed before executing the rest of the script?  Default is true.
  130.  
  131. stop optimize: Stop the current optimization
  132.     stop optimize
  133.  
  134. compute optimization index: Compute the optimization index(es) for the specified disk(s)
  135.     compute optimization index reference -- the disks to index  (a single disk or a list of disks)
  136.         [sensitivity  boolean] -- Should DiskExpress ignore user and i/o activity during indexing?  Default is true.
  137.         [waiting  boolean] -- Wait until indexing is completed before executing the rest of the script?  Default is true.
  138.  
  139. Class application: An application program
  140. Plural form:
  141.     applications
  142. Elements:
  143.     disk by ID, by numeric index, by name, as a range of elements, satisfying a test
  144.     item by ID, by numeric index, by name, as a range of elements, satisfying a test
  145. Properties:
  146.     frontmost boolean  [r/o]  -- Is this the frontmost application? 
  147.     name string  [r/o]  --  the name of the application
  148.     version version  [r/o]  --  the version of the application
  149.     current operation no operation /optimize operation / analyze operation / index operation  [r/o]  --  the current operation being performed on any disk
  150.     enabled boolean  -- Is DiskExpress on?   (Controls the On/Off radio buttons in the Optimization tab of the DiskExpress control panel.)
  151.     monitor all disks boolean  -- Should DiskExpress monitor all eligible disks?  (Controls the Monitor All checkbox in the Disk Options tab of the DiskExpress control panel.)
  152.     optimization activity sensitivity no sensitivity / low sensitivity / medium sensitivity / high sensitivity  --  sensitivity to i/o during optimizations (Controls the Input/Output Sensitivity slider in the Preferences dialog of the DiskExpress control panel.)
  153.     optimization scheduling boolean  --  Should DiskExpress  run scheduled optimizations? (Controls the On/Off radio buttons for Scheduled Optimizations in the Disk Options tab of the DiskExpress control panel.)
  154.     read and write verification boolean  --  Should DiskExpress  verify data while reading and writing disks during optimizations? (Controls the Verify Reads and Writes check box in the Preferences dialog of the DiskExpress control panel.)
  155.     schedule only when charger connected boolean  --  Should DiskExpress run scheduled optimizations only when charger is connected? (Controls the Schedule only when on AC adapter check box in the Preferences dialog of the DiskExpress control panel.)
  156.     startup disk reference  [r/o]  --  the startup disk
  157.  
  158. Class disk: A disk
  159. Plural form:
  160.     disks
  161. Elements:
  162.     file by ID, by numeric index, by name, as a range of elements, satisfying a test
  163.     folder by ID, by numeric index, by name, as a range of elements, satisfying a test
  164.     item by ID, by numeric index, by name, as a range of elements, satisfying a test
  165. Properties:
  166.     capacity unsigned integer  [r/o]  -- the total number of bytes (free or used) on the disk
  167.     ejectable boolean  [r/o]  --  Can the media be ejected (floppies, CD's, and so on)? 
  168.     entire contents reference  [r/o]  --  the entire contents of the disk, including the contents of its folders (Can be an unmanageably large list for disks containing many items.)
  169.     free space unsigned integer  [r/o]  -- the number of free bytes left on the disk
  170.     id  integer  [r/o]  --  an id that identifies the disk to the operating system
  171.     local volume boolean  [r/o]  --  Is the media a local volume (as opposed to a file server)?
  172.     name string  --  the name of the disk
  173.     startup boolean  [r/o]  --  Is the disk the boot disk?
  174.     current operation no operation /optimize operation / analyze operation / index operation  [r/o]  --  the current operation being performed on the disk
  175.     erase free space date date  [r/o]  --  the date on which the free space on the disk was last erased
  176.     last operation no operation /optimize operation / analyze operation / index operation  [r/o]  --  the last operation performed on the disk
  177.     last operation result integer  [r/o]  --  the result of the last operation performed on the disk
  178.     last optimization index unsigned integer  [r/o]  --  the last computed optimization index for the disk  (To determine the current optimization index, first use the compute optimization index command to force the index to be computed now.)  
  179.     last optimize files method split method / packed method / quick method / selected files method / free space method / unknown method  [r/o]  --  the method last used to optimize files on the disk
  180.     optimization index date date  [r/o]  --  the date on which the optimization index for the disk was last computed
  181.     optimize files date date  [r/o]  --  the date on which files were last optimized for the disk
  182.     verify directory date date  [r/o]  --  the date on which the disk's directory was last verified 
  183.     verify media date date  [r/o]  --  the date on which the disk's media was last verified 
  184.  
  185. Class file: A file
  186. Plural form:
  187.     files
  188. Properties:
  189.     container reference  [r/o]  --  the container of the file
  190.     creator type type class  --  the OSType identifying the application that created the file
  191.     file type type class  --  the OSType identifying the type of data contained in the file
  192.     id  integer  [r/o]  --  an id that identifies the file to the operating system
  193.     in system folder boolean  [r/o]  --  Is the file in the system folder?   (Is true if the file is in the System folder or any folder within the System folder.)
  194.     locked boolean  [r/o]  --  Is the file locked?   
  195.     name string  --  the name of the file
  196.     visible boolean  [r/o]  --  Is the file visible?   
  197.     access count unsigned integer  [r/o]  --  the number or recent accesses to the file
  198.     access date date  [r/o]  --  the date on which the file was last accessed
  199.     anchored boolean  [r/o]  --  Is the file anchored?   
  200.     fragmented boolean  [r/o]  --  Is the file fragmented?   
  201.     priority no priority / active priority / sporadic priority / dormant priority / special priority  --  the activity priority of the file
  202.     selected boolean  [r/o]  --  Is the file selected for selected files optimization?   
  203.  
  204. Class folder: A folder
  205. Plural form:
  206.     folders
  207. Elements:
  208.     file by ID, by numeric index, by name, as a range of elements, satisfying a test
  209.     folder by ID, by numeric index, by name, as a range of elements, satisfying a test
  210.     item by ID, by numeric index, by name, as a range of elements, satisfying a test
  211. Properties:
  212.     container reference  [r/o]  --  the container of the folder
  213.     entire contents reference  [r/o]  --  the entire contents of the folder, including the contents of its folders (Can be an unmanageably large list for folders containing many items.)
  214.     id  integer  [r/o]  --  an id that identifies the folder to the operating system
  215.     in system folder boolean  [r/o]  --  Is the folder in the system folder?  
  216.     name string  --  the name of the folder
  217.     visible boolean  [r/o]  --  Is the folder visible?   
  218.  
  219. Class item: An item
  220. Plural form:
  221.     items
  222.  
  223.  
  224. List of Errors Returned By the DiskExpress Extension Suite
  225.  
  226. Error
  227. number     Error message
  228. 1101          DiskExpress is busy performing another activity and cannot process this request.
  229. 1102          Verification was stopped because the disk was removed from the desktop or ejected.
  230. 1103          Optimization was stopped because the disk was removed from the desktop or ejected.
  231. 1104          Optimization was stopped because the disk was modified.
  232. 1105          DiskExpress found bad blocks during media verification.
  233. 1108          DiskExpress received a stop optimize event.
  234. 1110          Another copy of DiskExpress with the same serial number is already in use.
  235. 1111          An unexpected error occurred.
  236. 1113          An unexpected error occurred.
  237. 1114          An unexpected error occurred.
  238. 1115          An unexpected error occurred.
  239. 1116          Optimization was stopped due to a conflict with a System Extension or an incompatibility with the current System Software.
  240. 1123          The charger was disconnected while performing a scheduled optimization.
  241. 1127          Indexing was stopped because the disk was removed from the desktop or ejected.
  242. 1128          Indexing was stopped because the disk was modified.
  243. 1133          DiskExpress is turned off.
  244. 1134          Due to an error, the DiskExpress Pro Extension was not loaded completely.
  245. 1135          A required resource is missing. DiskExpress Pro may be damaged. Please reinstall from your original diskette.
  246. 1137          Directory verification was stopped because the disk was removed from the desktop or ejected.
  247. 1138          Directory verification was stopped because the disk was modified.
  248. 1141          Erase free space was stopped because the disk was removed from the desktop or ejected.
  249. 1142          Erase free space was stopped because the disk was modified.
  250. 1147          DiskExpress found directory errors during directory verification.
  251. 1148          DiskExpress found directory warnings during directory verification.
  252. 1151          DiskExpress is turned off and must be turned on by the DiskExpress Pro control panel.
  253. 1155          An operation was requested on a non Mac OS Standard (HFS) disk.